var t,
  a = require("../../@babel/runtime/helpers/defineProperty"),
  n = require("../../res/www.a9a.cn.js"),
  e = getApp(),
  i = 2,
  o = !0;
Page({
  data: {
    currentTab: 0,
    topbar2_btm: 0,
    if_div_top: !1,
    TOP3loading: !1,
    loading_flag: !1,
    loading_ico_flag: !1,
    loading_str: "玩命加载中",
  },
  onLoad: function (t) {
    var a = this;
    e.get_config("_ZEAI").then(function (t) {
      a.setData({
        color: e._ZEAI.color,
        rgbcolor: n.c16_rgb(e._ZEAI.color),
        nikbg: e.WWW + "/res/m/img/nikbg.png",
      }),
        n.set_tabbar();
    }),
      e.get_navigationBarTopHeight(a),
      (o = !0),
      e.get_openid().then(function (t) {
        a.init();
      }),
      e.chklogin().then(function (t) {});
  },
  init: function () {
    var i = this,
      o = {
        submitok: "index",
        openid: (t = wx.getStorageSync("COOK_U")).openid,
        unionid: t.unionid,
      };
    wx.showLoading({ title: "玩命加载中", mask: !0 }),
      e.ajax({
        url: "index4.php",
        data: o,
        success: function (e) {
          if ((wx.hideLoading(), e.cook_flag != t.flag && !i.data.singlePage))
            return (
              (t.flag = e.cook_flag),
              wx.setStorageSync("COOK_U", t),
              void i.onLoad()
            );
          if (1 == e.flag) {
            var o = e.banner;
            if (!n.empty(e.var.m_bottom)) var r = n.escape2Html(e.var.m_bottom);
            i.setData(
              a(
                {
                  topbar: e.topbar,
                  navdiy_index: e.navdiy_index,
                  TRnav: e.TRnav,
                  banner: o,
                  IZT: e.IZT,
                  TOP3: e.TOP3,
                  PARTY: e.PARTY,
                  HN: e.HN,
                  WZ: e.WZ,
                  m_bottom: r,
                  var: e.var,
                },
                "ARR_index[0]",
                e.ULIST
              )
            ),
              o.length > 0 &&
                n.o("#img0", function (t) {
                  i.setData({
                    banner_W: t[0].width,
                    banner_H: 0.288 * t[0].width,
                  });
                });
            var s = n.get_tabbar_index("my_msg");
            e.btmnewnum > 0
              ? wx.setTabBarBadge({ index: s, text: e.btmnewnum })
              : wx.removeTabBarBadge({ index: s });
          } else wx.showToast({ title: e.msg, icon: "none", mask: !0 });
        },
      });
  },
  onShow: function () {
    var a = this;
    (t = wx.getStorageSync("COOK_U")),
      e.empty(t) ||
        e.ajax({
          url: "index4.php",
          data: { submitok: "onshow", openid: t.openid, unionid: t.unionid },
          success: function (n) {
            if (1 == n.flag && n.cook_flag != t.flag)
              return (
                (t.flag = n.cook_flag),
                wx.setStorageSync("COOK_U", t),
                void a.onPullDownRefresh()
              );
          },
        });
  },
  setloading: function (t, a) {
    "start" == t
      ? this.setData({ loading_flag: !0, loading_ico_flag: !0, loading_str: a })
      : this.setData({
          loading_flag: !1,
          loading_ico_flag: !1,
          loading_str: a,
        });
  },
  onPullDownRefresh: function () {
    var t = this;
    wx.vibrateShort({ type: "heavy" }),
      setTimeout(function () {
        t.setData({
          loading_flag: !1,
          loading_str: "拼命加载中",
          ARR_index: [],
          ARR_index_nodata: !1,
          guestloadP_flag: !1,
          sokind: "",
          currentTab: 0,
        }),
          (i = 2),
          (o = !0),
          wx.stopPullDownRefresh(),
          t.init();
      }, 100);
  },
  onReachBottom: function (n) {
    if (1 == this.data.var.index_ifpbl) {
      var r = this.data.ARR_index,
        s = this;
      if (o) {
        (o = !1), s.setloading("start", "玩命加载中");
        var l = { submitok: "list", p: i, openid: t.openid };
        e.ajax({
          url: "index4.php",
          data: l,
          success: function (t) {
            if (i > s.data.var.guestloadP && 1 != s.data.var.iflogin)
              return (
                s.setloading("stop", "请登录/注册"),
                (o = !1),
                void s.setData({ guestloadP_flag: !0 })
              );
            if (1 == t.flag) {
              var n = r.length;
              if (t.ULIST.length < 1)
                return s.setloading("end", "已全部加载完毕"), void (o = !1);
              s.setData(a({}, "ARR_index[" + n + "]", t.ULIST)),
                (i += 1),
                (o = !0);
            } else wx.showToast({ title: t.msg, icon: "none", mask: !0 });
            s.setloading("end", "上拉加载更多");
          },
        });
      }
    }
  },
  getPhoneNumber: function (t) {
    e.getPhoneNumber({ e: t, url: "../reg/reg" });
  },
  topbarFn: function (t) {
    switch (t.currentTarget.dataset.f) {
      case "trend":
        wx.navigateTo({ url: "../trend/trend" });
        break;
      case "izt":
        wx.navigateTo({ url: "../izt/izt" });
    }
  },
  topbar_moreFn: function () {
    this.setData({
      if_div_top: !0,
      div_top_mask_class: "alpha0_100",
      div_top_box_class: "divTopDown",
    });
  },
  div_top_close_Fn: function () {
    var t = this;
    this.setData({ div_top_box_class: "divTopUp" }),
      setTimeout(function () {
        t.setData({ div_top_mask_class: "alpha100_0" });
      }, 200),
      setTimeout(function () {
        t.setData({ if_div_top: !1 });
      }, 400);
  },
  blankFn: function () {},
  top3Fn: function () {
    var n = this;
    n.setData({ TOP3loading: !0 }),
      e.ajax({
        url: "index4.php",
        data: { submitok: "top3", openid: t.openid },
        success: function (t) {
          1 == t.flag
            ? n.setData(a({}, "TOP3", t.TOP3))
            : wx.showToast({ title: t.msg, icon: "none", mask: !0 }),
            n.setData({ TOP3loading: !1 });
        },
      });
  },
  WZkindFn: function (t) {
    var a = t.currentTarget.dataset.kind;
    wx.navigateTo({ url: "../article/article?kind=" + a });
  },
  index_parFn: function (t) {
    var a = t.currentTarget.dataset.sokind,
      n = t.currentTarget.dataset.sex;
    (e.globalData.index_par = { sokind: a, sex: n }),
      wx.switchTab({ url: "../user/user" });
  },
  onPageScroll: function (t) {
    t.scrollTop > 100
      ? this.setData({ backtop_flag: !0, topbar2: !0, topbar2_btm: 10 })
      : this.setData({ backtop_flag: !1, topbar2: !1, topbar2_btm: 0 });
  },
  backtopFn: function (t) {
    wx.pageScrollTo({ scrollTop: 0, duration: 300 });
  },
  telFn: function (t) {
    wx.makePhoneCall({ phoneNumber: this.data.var.tel });
  },
  onShareAppMessage: function () {
    return {
      imageUrl: this.data.var.share.imgurl,
      title: this.data.var.share.title,
      path: "/pages/index/index4",
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.data.var.share.imgurl,
      title: this.data.var.share.title,
      query: "",
      path: "/pages/index/index4",
    };
  },
  privacy_agree: function (t) {
    console.log("agree");
  },
  privacy_disagree: function (t) {
    console.log("disagree"), wx.exitMiniProgram();
  },
});
